package com.hsjk.szwj.module.official.controller.app.unit;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.framework.security.core.annotations.PreAuthenticated;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleBannerDetailRespVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleBannerPageReqVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleBannerPageRespVO;
import com.hsjk.szwj.module.official.service.unit.IUnitService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/11/26 20:33
 **/
@Tag(name = "前端 - 官网模块化banner相关接口")
@RestController
@RequestMapping("/official-website/unit/banner")
@Validated
public class AppUnitBannerController {
    @Resource
    private IUnitService unitService;

    @GetMapping("/get-banner-by-id")
    @Operation(summary = "根据bannerid获取banner详情")
    @PreAuthenticated
    public CommonResult<AppModuleBannerDetailRespVO> getAppModuleBannerDetail(@RequestParam Long id) {
        return success(unitService.getAppModuleBannerDetail(id));
    }

    @PostMapping("/page")
    @Operation(summary = "banner分页查询")
    @PreAuthenticated
    public CommonResult<PageResult<AppModuleBannerPageRespVO>> getAppModuleBannerPage(@RequestBody @Valid AppModuleBannerPageReqVO reqVO) {
        return success(unitService.getAppModuleBannerPage(reqVO));
    }
}
